#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>

char* strerror(int err);

static void* thread_func(void* arg)
{
  char *str;
  printf("Other thread about to call strerror()\n");
  str = strerror(EPERM);
  printf("Other thread: str (%p) = %s\n",str,str);
  return NULL;
}

int main(int argc, char *argv[])
{
  pthread_t t;
  int s;
  char *str;

  str = strerror(EINVAL);
  printf("Main thread has called strerror()\n");
  printf("Main thread: str (%p) = %s\n",str,str);

  s = pthread_create(&t, NULL, thread_func, NULL);
  if (s!=0)
    printf("Failed to create thread\n");
  s = pthread_join(t,NULL);
  if (s!=0)
    printf("Failed to join thread\n");
  printf("Main thread: str (%p) = %s\n",str,str);

  return 0;
}
